package controllers

import (
	"encoding/json"
	"gobuild/services"

	"github.com/astaxie/beego"
)

type JobController struct {
	beego.Controller
}

// @router /services/JobService/SaveJob [post]
func (c *JobController) SaveJob() {
	ret := true
	var dat map[string]interface{}
	jsonStr := c.GetString("content")
	var err error
	if err = json.Unmarshal([]byte(jsonStr), &dat); err == nil {
		err = services.JobService.SaveJob(dat)
	}
	if err != nil {
		ret = false
	}
	c.Data["json"] = map[string]interface{}{"result": ret}
	c.ServeJSON()

}

// @router /services/JobService/GetJobDropDown [post]
func (c *JobController) GetJobDropDown() {

	content, _ := services.JobService.GetJobDropDown()

	c.Data["json"] = &content
	c.ServeJSON()

}
